\(\int \text {sech}(c+d x) (a+b \tanh ^2(c+d x)) \, dx\) [85]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [B] (verification not implemented)
   Giac [B] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 19, antiderivative size = 40 \[ \int \text {sech}(c+d x) \left (a+b \tanh ^2(c+d x)\right ) \, dx=\frac {(2 a+b) \arctan (\sinh (c+d x))}{2 d}-\frac {b \text {sech}(c+d x) \tanh (c+d x)}{2 d} \]

[Out]

1/2*(2*a+b)*arctan(sinh(d*x+c))/d-1/2*b*sech(d*x+c)*tanh(d*x+c)/d

Rubi [A] (verified)

Time = 0.02 (sec) , antiderivative size = 40, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.158, Rules used = {3757, 393, 209} \[ \int \text {sech}(c+d x) \left (a+b \tanh ^2(c+d x)\right ) \, dx=\frac {(2 a+b) \arctan (\sinh (c+d x))}{2 d}-\frac {b \tanh (c+d x) \text {sech}(c+d x)}{2 d} \]

[In]

Int[Sech[c + d*x]*(a + b*Tanh[c + d*x]^2),x]

[Out]

((2*a + b)*ArcTan[Sinh[c + d*x]])/(2*d) - (b*Sech[c + d*x]*Tanh[c + d*x])/(2*d)

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 393

Int[((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_)), x_Symbol] :> Simp[(-(b*c - a*d))*x*((a + b*x^n)^(p
 + 1)/(a*b*n*(p + 1))), x] - Dist[(a*d - b*c*(n*(p + 1) + 1))/(a*b*n*(p + 1)), Int[(a + b*x^n)^(p + 1), x], x]
 /; FreeQ[{a, b, c, d, n, p}, x] && NeQ[b*c - a*d, 0] && (LtQ[p, -1] || ILtQ[1/n + p, 0])

Rule 3757

Int[sec[(e_.) + (f_.)*(x_)]^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]^(n_))^(p_.), x_Symbol] :> With[{ff = F
reeFactors[Sin[e + f*x], x]}, Dist[ff/f, Subst[Int[ExpandToSum[b*(ff*x)^n + a*(1 - ff^2*x^2)^(n/2), x]^p/(1 -
ff^2*x^2)^((m + n*p + 1)/2), x], x, Sin[e + f*x]/ff], x]] /; FreeQ[{a, b, e, f}, x] && IntegerQ[(m - 1)/2] &&
IntegerQ[n/2] && IntegerQ[p]

Rubi steps \begin{align*} \text {integral}& = \frac {\text {Subst}\left (\int \frac {a+(a+b) x^2}{\left (1+x^2\right )^2} \, dx,x,\sinh (c+d x)\right )}{d} \\ & = -\frac {b \text {sech}(c+d x) \tanh (c+d x)}{2 d}+\frac {(2 a+b) \text {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\sinh (c+d x)\right )}{2 d} \\ & = \frac {(2 a+b) \arctan (\sinh (c+d x))}{2 d}-\frac {b \text {sech}(c+d x) \tanh (c+d x)}{2 d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.01 (sec) , antiderivative size = 48, normalized size of antiderivative = 1.20 \[ \int \text {sech}(c+d x) \left (a+b \tanh ^2(c+d x)\right ) \, dx=\frac {a \arctan (\sinh (c+d x))}{d}+\frac {b \arctan (\sinh (c+d x))}{2 d}-\frac {b \text {sech}(c+d x) \tanh (c+d x)}{2 d} \]

[In]

Integrate[Sech[c + d*x]*(a + b*Tanh[c + d*x]^2),x]

[Out]

(a*ArcTan[Sinh[c + d*x]])/d + (b*ArcTan[Sinh[c + d*x]])/(2*d) - (b*Sech[c + d*x]*Tanh[c + d*x])/(2*d)

Maple [A] (verified)

Time = 0.62 (sec) , antiderivative size = 56, normalized size of antiderivative = 1.40

method result size
derivativedivides \(\frac {2 a \arctan \left ({\mathrm e}^{d x +c}\right )+b \left (-\frac {\sinh \left (d x +c \right )}{\cosh \left (d x +c \right )^{2}}+\frac {\operatorname {sech}\left (d x +c \right ) \tanh \left (d x +c \right )}{2}+\arctan \left ({\mathrm e}^{d x +c}\right )\right )}{d}\) \(56\)
default \(\frac {2 a \arctan \left ({\mathrm e}^{d x +c}\right )+b \left (-\frac {\sinh \left (d x +c \right )}{\cosh \left (d x +c \right )^{2}}+\frac {\operatorname {sech}\left (d x +c \right ) \tanh \left (d x +c \right )}{2}+\arctan \left ({\mathrm e}^{d x +c}\right )\right )}{d}\) \(56\)
risch \(-\frac {b \,{\mathrm e}^{d x +c} \left ({\mathrm e}^{2 d x +2 c}-1\right )}{d \left ({\mathrm e}^{2 d x +2 c}+1\right )^{2}}+\frac {i \ln \left ({\mathrm e}^{d x +c}+i\right ) a}{d}+\frac {i b \ln \left ({\mathrm e}^{d x +c}+i\right )}{2 d}-\frac {i \ln \left ({\mathrm e}^{d x +c}-i\right ) a}{d}-\frac {i b \ln \left ({\mathrm e}^{d x +c}-i\right )}{2 d}\) \(106\)

[In]

int(sech(d*x+c)*(a+b*tanh(d*x+c)^2),x,method=_RETURNVERBOSE)

[Out]

1/d*(2*a*arctan(exp(d*x+c))+b*(-sinh(d*x+c)/cosh(d*x+c)^2+1/2*sech(d*x+c)*tanh(d*x+c)+arctan(exp(d*x+c))))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 323 vs. \(2 (36) = 72\).

Time = 0.25 (sec) , antiderivative size = 323, normalized size of antiderivative = 8.08 \[ \int \text {sech}(c+d x) \left (a+b \tanh ^2(c+d x)\right ) \, dx=-\frac {b \cosh \left (d x + c\right )^{3} + 3 \, b \cosh \left (d x + c\right ) \sinh \left (d x + c\right )^{2} + b \sinh \left (d x + c\right )^{3} - {\left ({\left (2 \, a + b\right )} \cosh \left (d x + c\right )^{4} + 4 \, {\left (2 \, a + b\right )} \cosh \left (d x + c\right ) \sinh \left (d x + c\right )^{3} + {\left (2 \, a + b\right )} \sinh \left (d x + c\right )^{4} + 2 \, {\left (2 \, a + b\right )} \cosh \left (d x + c\right )^{2} + 2 \, {\left (3 \, {\left (2 \, a + b\right )} \cosh \left (d x + c\right )^{2} + 2 \, a + b\right )} \sinh \left (d x + c\right )^{2} + 4 \, {\left ({\left (2 \, a + b\right )} \cosh \left (d x + c\right )^{3} + {\left (2 \, a + b\right )} \cosh \left (d x + c\right )\right )} \sinh \left (d x + c\right ) + 2 \, a + b\right )} \arctan \left (\cosh \left (d x + c\right ) + \sinh \left (d x + c\right )\right ) - b \cosh \left (d x + c\right ) + {\left (3 \, b \cosh \left (d x + c\right )^{2} - b\right )} \sinh \left (d x + c\right )}{d \cosh \left (d x + c\right )^{4} + 4 \, d \cosh \left (d x + c\right ) \sinh \left (d x + c\right )^{3} + d \sinh \left (d x + c\right )^{4} + 2 \, d \cosh \left (d x + c\right )^{2} + 2 \, {\left (3 \, d \cosh \left (d x + c\right )^{2} + d\right )} \sinh \left (d x + c\right )^{2} + 4 \, {\left (d \cosh \left (d x + c\right )^{3} + d \cosh \left (d x + c\right )\right )} \sinh \left (d x + c\right ) + d} \]

[In]

integrate(sech(d*x+c)*(a+b*tanh(d*x+c)^2),x, algorithm="fricas")

[Out]

-(b*cosh(d*x + c)^3 + 3*b*cosh(d*x + c)*sinh(d*x + c)^2 + b*sinh(d*x + c)^3 - ((2*a + b)*cosh(d*x + c)^4 + 4*(
2*a + b)*cosh(d*x + c)*sinh(d*x + c)^3 + (2*a + b)*sinh(d*x + c)^4 + 2*(2*a + b)*cosh(d*x + c)^2 + 2*(3*(2*a +
 b)*cosh(d*x + c)^2 + 2*a + b)*sinh(d*x + c)^2 + 4*((2*a + b)*cosh(d*x + c)^3 + (2*a + b)*cosh(d*x + c))*sinh(
d*x + c) + 2*a + b)*arctan(cosh(d*x + c) + sinh(d*x + c)) - b*cosh(d*x + c) + (3*b*cosh(d*x + c)^2 - b)*sinh(d
*x + c))/(d*cosh(d*x + c)^4 + 4*d*cosh(d*x + c)*sinh(d*x + c)^3 + d*sinh(d*x + c)^4 + 2*d*cosh(d*x + c)^2 + 2*
(3*d*cosh(d*x + c)^2 + d)*sinh(d*x + c)^2 + 4*(d*cosh(d*x + c)^3 + d*cosh(d*x + c))*sinh(d*x + c) + d)

Sympy [F]

\[ \int \text {sech}(c+d x) \left (a+b \tanh ^2(c+d x)\right ) \, dx=\int \left (a + b \tanh ^{2}{\left (c + d x \right )}\right ) \operatorname {sech}{\left (c + d x \right )}\, dx \]

[In]

integrate(sech(d*x+c)*(a+b*tanh(d*x+c)**2),x)

[Out]

Integral((a + b*tanh(c + d*x)**2)*sech(c + d*x), x)

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 80 vs. \(2 (36) = 72\).

Time = 0.28 (sec) , antiderivative size = 80, normalized size of antiderivative = 2.00 \[ \int \text {sech}(c+d x) \left (a+b \tanh ^2(c+d x)\right ) \, dx=-b {\left (\frac {\arctan \left (e^{\left (-d x - c\right )}\right )}{d} + \frac {e^{\left (-d x - c\right )} - e^{\left (-3 \, d x - 3 \, c\right )}}{d {\left (2 \, e^{\left (-2 \, d x - 2 \, c\right )} + e^{\left (-4 \, d x - 4 \, c\right )} + 1\right )}}\right )} + \frac {a \arctan \left (\sinh \left (d x + c\right )\right )}{d} \]

[In]

integrate(sech(d*x+c)*(a+b*tanh(d*x+c)^2),x, algorithm="maxima")

[Out]

-b*(arctan(e^(-d*x - c))/d + (e^(-d*x - c) - e^(-3*d*x - 3*c))/(d*(2*e^(-2*d*x - 2*c) + e^(-4*d*x - 4*c) + 1))
) + a*arctan(sinh(d*x + c))/d

Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 84 vs. \(2 (36) = 72\).

Time = 0.29 (sec) , antiderivative size = 84, normalized size of antiderivative = 2.10 \[ \int \text {sech}(c+d x) \left (a+b \tanh ^2(c+d x)\right ) \, dx=\frac {{\left (\pi + 2 \, \arctan \left (\frac {1}{2} \, {\left (e^{\left (2 \, d x + 2 \, c\right )} - 1\right )} e^{\left (-d x - c\right )}\right )\right )} {\left (2 \, a + b\right )} - \frac {4 \, b {\left (e^{\left (d x + c\right )} - e^{\left (-d x - c\right )}\right )}}{{\left (e^{\left (d x + c\right )} - e^{\left (-d x - c\right )}\right )}^{2} + 4}}{4 \, d} \]

[In]

integrate(sech(d*x+c)*(a+b*tanh(d*x+c)^2),x, algorithm="giac")

[Out]

1/4*((pi + 2*arctan(1/2*(e^(2*d*x + 2*c) - 1)*e^(-d*x - c)))*(2*a + b) - 4*b*(e^(d*x + c) - e^(-d*x - c))/((e^
(d*x + c) - e^(-d*x - c))^2 + 4))/d

Mupad [B] (verification not implemented)

Time = 0.12 (sec) , antiderivative size = 125, normalized size of antiderivative = 3.12 \[ \int \text {sech}(c+d x) \left (a+b \tanh ^2(c+d x)\right ) \, dx=\frac {\mathrm {atan}\left (\frac {{\mathrm {e}}^{d\,x}\,{\mathrm {e}}^c\,\left (2\,a\,\sqrt {d^2}+b\,\sqrt {d^2}\right )}{d\,\sqrt {4\,a^2+4\,a\,b+b^2}}\right )\,\sqrt {4\,a^2+4\,a\,b+b^2}}{\sqrt {d^2}}-\frac {b\,{\mathrm {e}}^{c+d\,x}}{d\,\left ({\mathrm {e}}^{2\,c+2\,d\,x}+1\right )}+\frac {2\,b\,{\mathrm {e}}^{c+d\,x}}{d\,\left (2\,{\mathrm {e}}^{2\,c+2\,d\,x}+{\mathrm {e}}^{4\,c+4\,d\,x}+1\right )} \]

[In]

int((a + b*tanh(c + d*x)^2)/cosh(c + d*x),x)

[Out]

(atan((exp(d*x)*exp(c)*(2*a*(d^2)^(1/2) + b*(d^2)^(1/2)))/(d*(4*a*b + 4*a^2 + b^2)^(1/2)))*(4*a*b + 4*a^2 + b^
2)^(1/2))/(d^2)^(1/2) - (b*exp(c + d*x))/(d*(exp(2*c + 2*d*x) + 1)) + (2*b*exp(c + d*x))/(d*(2*exp(2*c + 2*d*x
) + exp(4*c + 4*d*x) + 1))